/**
 * 
 */

/**
 * @author antonio081014
 * @since Nov 17, 2011, 8:03:13 AM
 */
import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;
import java.awt.geom.*;

public class ShippingCubes {
	public int minimalCost(int N) {
		int mmin = Integer.MAX_VALUE;
		for (int a = 1; a <= N; a++) {
			for (int b = 1; b <= N; b++) {
				for (int c = 1; c <= N; c++) {
					if (a * b * c == N) {
						mmin = Math.min(mmin, a + b + c);
					}
				}
			}
		}
		return mmin;
	}

	// <%:testing-code%>
}
// Powered by [KawigiEdit] 2.0!
